package com.nf.bookstytem.model.page;

public class Pagination {
	private int pageNo;
	private int pageSize = 5;
	private int recordCount ;
	private int pageCount = 0;
	
	public Pagination(){
		
	}
	
	public Pagination(int pageNo,int recordCount){
		this(pageNo,5,recordCount);
		
	}
	
	public Pagination(int pageNo,int pageSize,int recordCount){
		this.pageNo = pageNo;
		this.pageSize = pageSize;
		this.recordCount = recordCount;
		init();
	}
	private void init(){
		this.pageCount = (int)Math.ceil(recordCount*1.0/pageSize);
	}
	public int getFirst(){
		return 1;
	}
	
	public int getLast(){
		return this.pageCount;
	}
	
	public int getPrev(){
		return Math.max(1, this.pageNo -1);
	}
	
	public int getNext(){
		return Math.min(this.pageCount, this.pageNo + 1);
	}
}
